import { defineStore } from "pinia";
import { ref } from "vue";
import { getLoginApi } from '@/apis/login'

export const useLoginStore = defineStore('user', () => {
    const userinfo = ref()

    const getUserDate = async ({ account, password }) => {
        const res = await getLoginApi({ account, password })
        userinfo.value = res.result
    }
    const clearData = () => {
        userinfo.value = {}
    }

    return {
        userinfo,
        getUserDate,
        clearData
    }
}, { persist: true }
)